﻿using System;
using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json;

namespace Elight.WebApi.Responses
{
    /// <summary>
    /// AJAX请求响应数据格式模型。
    /// </summary>
    [Serializable]
    public class AjaxResult
    {
        /// <summary>
        /// 构造AJAX响应模型。
        /// </summary>
        /// <param name="status">结果类型 ResultTypes</param>
        /// <param name="message">消息内容</param>
        /// <param name="data">响应数据</param>
        public AjaxResult(string status, string message, object data = null)
        {
            this.Status = status;
            this.Message = message;
            this.Data = data;
        }

        [JsonProperty("status")]
        public string Status { get; set; }

        [JsonProperty("message")]
        public string Message { get; set; }

        [JsonProperty("data")]
        public object Data { get; set; }
    }

    /// <summary>
    /// 结果类型。
    /// </summary>
    public struct ResultTypes
    {
        /// <summary>
        /// 成功。
        /// </summary>
        public const string Success = "success";

        /// <summary>
        /// 消息。
        /// </summary>
        public const string Info = "info";

        /// <summary>
        /// 警告。
        /// </summary>
        public const string Warning = "warning";

        /// <summary>
        /// 异常。
        /// </summary>
        public const string Error = "error";
    }

}
